package com.fantasy.service;

import java.util.ArrayList;

import android.app.Service;
import android.content.Intent;
import android.os.Handler;
import android.os.IBinder;
import android.os.Message;
import android.os.Messenger;

public class WinLocalService extends Service {

	ArrayList<Messenger> mClients = new ArrayList<Messenger>();
	public static final int MSG_USER_LOGIN = 0;
	public static final int MSG_USER_QUIT = 2;

	final Messenger  mMessenger = new Messenger(new IncomingHandler());
	@Override
	public IBinder onBind(Intent intent) {
		return mMessenger.getBinder();
	}

	@Override
	public void onCreate() {
		super.onCreate();
	}

	class IncomingHandler extends Handler {

		@Override
		public void handleMessage(Message msg) {
			super.handleMessage(msg);
			switch (msg.what) {
			case MSG_USER_LOGIN:
				mClients.add(msg.replyTo);
				break;
			case MSG_USER_QUIT:
				mClients.remove(msg.replyTo);
				break;
			}
		}

	}
}
